Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(changelog): expose commit parents #1376

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

unleashed
Copy link

Description

Expose commit parent(s) digests to the changelog process. This has an application
for projects that want to generate changelogs based on merge commits only, but it
is likely useful in more contexts, for example listing commits that belong to the same
PR under its own section.

Checklist

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

The changelog generation code exposes the parents field with a list of parent
digests in git commits.

Steps to Test This Pull Request

You can create a changelog template iterating the parents field of changes and
for merge commits you should have at least 2 parents.

Additional context

Useful in the git workflow I'm currently working on, where merge commits cannot
be told apart by the changelog generation machinery and I need to distinguish them
as they are the only ones that can be taken into account without rewriting the project's
git history due to using varied standards throughout its life.

Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.55%. Comparing base (120d514) to head (ca410a4).
Report is 581 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1376      +/-   ##
==========================================
+ Coverage   97.33%   97.55%   +0.21%     
==========================================
  Files          42       57      +15     
  Lines        2104     2656     +552     
==========================================
+ Hits         2048     2591     +543     
- Misses         56       65       +9     
Flag Coverage Δ
unittests 97.55% <100.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@noirbizarre noirbizarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

Good to me after the default list handling is fixed 👍🏼

@@ -507,6 +507,7 @@ Each `Change` has the following fields:
| scope | `str | None` | An optional scope |
| message | `str` | The commit message body |
| sha1 | `str` | The commit `sha1` |
| parents | `list[str]` | The parent commit(s) `sha1`(s) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add more information to this section, specially what's it useful for:

Example usage: generate changelogs based on merge commits only, or listing commits that belong to the same PR under its own section.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added similar phrasing just below this table after the note. Let me know if that's ok.

@woile
Copy link
Member

woile commented Apr 9, 2025

LGTM! After issues have been addressed we can merge, thanks!

COMMIT_DATA in test_changelog.py had to be type annotated to avoid an
issue with mypy linting when creating a GitCommit where the tool would
expect the wrong type for the arguments.
@unleashed unleashed force-pushed the feature/changelog/expose-commit-parents branch from b8d8ab7 to ca410a4 Compare April 9, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants